const path = require('path')
const ESLintPlugin = require('eslint-webpack-plugin');
module.exports = {
    /*
    依赖
    在webpack5中eslint-loader已经弃用，能使用eslint-webpack-plugin 
   webpack5: eslint  eslint-webpack-plugin   eslint-plugin-import   eslint-config-airbnb-base
   webpack4: eslint   eslint-loader  eslint-plugin-import   eslint-config-airbnb-base
    */
    entry: './index.js',
    output: {
        filename: 'index.js',
        path: path.resolve(__dirname, 'dist')
    },
    module: {
        rules: [//eslint-loader eslint
            //只检查自己写的代码 第三方库不进行检查
            //设置检查规则
            // package.json中eslintConfig
            // "eslintConfig": {
            //     "extends": "airbnb-base"
            //   }
            //webpack5废弃以下
            // {
            //     test: /\.js$/i,
            //     loader: 'eslint-loader',
            //     exclude: /node_modules/,
            //     options: {
            //         fix: true//自动修改eslint错误
            //     }
            // }
        ]
    },
    plugins: [
        new ESLintPlugin({
            exclude:'node_modules', //排除node_modules文件夹的eslint检查
            fix:true //自动修复js格式错误
          })
    ],
    mode: 'development'
}